﻿using System;
using Entidades.jSON;
using Web.Helpers;
using Common;

namespace Web
{
    public partial class MasterPage : System.Web.UI.MasterPage
    {
        #region Properties

        public UsuarioInfo CurrentUser { get; set; }
        public LocalizationHelper.LocalizationSettings LocalizationSettings { get; set; }

        #endregion

        #region Constants

        public const int GRID_DEFAULT_PAGE_SIZE = WellKnownKeys.Grid.Settings.DEFAULT_PAGE_SIZE;

        public const int GRID_DEFAULT_WIDTH = WellKnownKeys.Grid.Settings.DEFAULT_WIDTH;

        public const int GRID_DEFAULT_HEIGHT = WellKnownKeys.Grid.Settings.DEFAULT_HEIGHT;

        public const string GRID_TITLE_FORMAT = "<span style='color:white; text-shadow:1px 1px 1px gray; font-weight:bold' >{0} </span><span style='color:white; text-shadow:1px 1px 1px gray; text-decoration:underline; font-weight:bold' >{1}</span>";

        #endregion

        #region Events

        protected void Page_Load(object sender, EventArgs e)
        {
            Helpers.SecurityHelper.ValidatePageAccess();

            #region Localization

            System.Globalization.CultureInfo cultureInfo = null;

            //var clientLanguages = Request.UserLanguages;
            //if (clientLanguages != null && clientLanguages.Length > 0)
            //    cultureInfo = new System.Globalization.CultureInfo(clientLanguages.FirstOrDefault());
            cultureInfo = new System.Globalization.CultureInfo("es-AR");
            System.Threading.Thread.CurrentThread.CurrentCulture = cultureInfo;

            this.LocalizationSettings = LocalizationHelper.GetLocalizationSettings(cultureInfo);
            
            #endregion

            #region Current User

            var usuario = Helpers.SessionHelper.GetCurrentUser();
            if (usuario != null)
                this.CurrentUser = usuario;

            #endregion
        }

        #endregion

        #region Private Methods
        #endregion
    }
}